home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / pascal / tppop16.zip / TPOP.ASM < prev    next >
Assembly Source File  |  1988-10-05  |  20KB  |  518 lines

  1. TITLE   Turbo Pop Version 1.6 beta
  2. SUBTTL  Copyright (c)1988 Ross Neilson Wentworth
  3.  
  4. ; This code is Copyright (c)1988 by Ross Neilson Wentworth
  5. ; All Rights Reserved
  6. ;
  7. ; No part of this code may be reproduced, modified, sold, or used
  8. ; as an incentive to buy without the expressed written consent of
  9. ; the author.
  10.  
  11.  
  12. ; Routine Quick Reference
  13. ;
  14. ;   EnterPopUp          Saves and sets the stack then calls a high-level routine
  15. ;   InitializePopUp     Sets the low-level interrupt vectors
  16. ;   Installed           Sees if the program is already loaded
  17. ;   new05Int            Optional print-screen trap
  18. ;   new09int            Checks for our hotkey combo at each keypress
  19. ;   new10Int            Optional video BIOS trap
  20. ;   new13int            Keeps track of when the disk is busy
  21. ;   new1Cint            Called at each timer tick and checks to see if we
  22. ;                       want to pop up and whether it is safe to do so
  23. ;   new28int            Interrupt routine that is called whenever it is safe
  24. ;                       to interrupt DOS
  25. ;   new2Fint            Intercepts the Multiplex interupt
  26.  
  27. TRUE     equ    1
  28. FALSE    equ    0
  29.  
  30. TRAPINT05  EQU  FALSE    ; change to TRUE to trap print-screens
  31. TRAPINT10  EQU  FALSE    ; change to TRUE to trap video BIOS
  32.  
  33. PUBLIC InitializePopUp,Installed
  34.  
  35. CSEG  SEGMENT PARA PUBLIC 'CODE'
  36.       ASSUME  CS:CSEG
  37.  
  38. EXTRN callpopup:FAR,ReleaseProgram:FAR
  39.  
  40. ;----------------------------------------------------------------------------
  41. ; Miscellaneous data
  42. ;----------------------------------------------------------------------------
  43. hotkey  LABEL  WORD
  44. scancode       DB  0    ; scan code of our hotkey
  45. shiftstatus    DB  0    ; shift key status (alt,ctrl, etc. )
  46.  
  47. program_status DB  0    ; true if the program is active
  48. request_flag   DB  0    ; true if we want to pop-up
  49. notsafe        DB  0    ; non-zero if unsafe to pop up
  50. multiplexID    DB  0    ; unique program ID code
  51.  
  52. stack_pointer  DW  0    ; holds our program's stack pointer
  53. stack_segment  DW  0    ; holds our program's stack segment
  54. old_pointer    DW  0    ; holds the interrupted stack pointer
  55. old_stack      DW  0    ; holds the interrupted stack segment
  56.  
  57. dos_busy_flag  DD  0       ; points to DOS's busy flag
  58.  
  59. ; Follows is the interrupt service routine (ISR) installation table.
  60. ; Each interrupt will have three entries, the interrupt number, the
  61. ; original interrupt vector, and the offset of the ISR.  The entire
  62. ; table is terminated with a zero byte (this disallows the automatic
  63. ; installation of interrupt 00h).  There are two ISR's that are optional.
  64. ; One traps the print-screen interrupt (05h) and the other traps the video
  65. ; BIOS interrupt (10h).  By default, these traps are not used.  If you wish
  66. ; to include them in the interrupt trapping list you must change the EQU's
  67. ; above to TRUE.  TRAPINT05 is the EQU for trapping the print-screen
  68. ; interrupt and TRAPINT10 is the EQU for trapping the video BIOS.
  69.  
  70. ;----------------------------------------------------------------------------
  71. ; Interrupt Vector Table
  72. ;----------------------------------------------------------------------------
  73.  
  74. Vectors  LABEL   BYTE
  75.  
  76. IF TRAPINT05   ; optional interrupt trap
  77.  
  78.                DB  05h     ; print screen vector number
  79. old05int       DD  ?       ; the original print screen interrupt vector
  80.                DW  offset new05int
  81. ENDIF
  82.  
  83.                DB  09h     ; keyboard vector number
  84. old09int       DD  ?       ; the original keyboard interrupt vector
  85.                DW  offset new09int
  86.  
  87. IF TRAPINT10   ; optional interrupt trap
  88.  
  89.                DB  10h     ; video BIOS vector number
  90. old10int       DD  ?       ; the original video BIOS interrupt vector
  91.                DW  offset new10int
  92. ENDIF
  93.  
  94.                DB  13h     ; disk i/o vector number
  95. old13int       DD  ?       ; the original disk interrupt vector
  96.                DW  offset new13int
  97.  
  98.                DB  1Ch     ; timer vector number
  99. old1Cint       DD  ?       ; the original timer interrupt vector
  100.                DW  offset new1Cint
  101.  
  102.                DB  28h     ; backprocess vector number
  103. old28int       DD  ?       ; the original backprocess interrupt vector
  104.                DW  offset new28int
  105.  
  106.                DB  2Fh     ; multiplex interrupt
  107. old2Fint       DD  ?       ; the original multiplex interrupt vector
  108.                DW  offset new2Fint
  109.  
  110.                DB  0       ; end of table
  111.  
  112. ;----------------------------------------------------------------------------
  113. ; Print-Screen Interrupt Service Routine - 05h
  114. ;----------------------------------------------------------------------------
  115. ; This is an optional interrupt trap.  Change the value of TRAPINT05 to
  116. ; TRUE if you want it compiled.  This one traps the PRINT SCREEN interrupt
  117. ; and prevents popping up in the middle of a screen print.
  118.  
  119. IF  trapInt05
  120.  
  121. new05int PROC  FAR
  122.  
  123.          inc       cs:[notsafe]        ; increment status flag
  124.  
  125.          pushf
  126.          cli
  127.          call      cs:[old05int]       ; chain to original INT 05h handler
  128.  
  129.          pushf                         ; preserve flags
  130.          dec       cs:[notsafe]        ; decrement status flag
  131.          popf                          ; restore flags
  132.  
  133.          sti                           ; enable interrupts
  134.          ret       2                   ; return with flags
  135.  
  136. new05int ENDP
  137.  
  138. ENDIF
  139.  
  140. ;----------------------------------------------------------------------------
  141. ; Keyboard Interrupt Service Routine - 09h
  142. ;----------------------------------------------------------------------------
  143. ; Every keystroke is checked through here for our hot_key combination.
  144. ; If our's is pressed, a service request flag is set to TRUE.  If the
  145. ; program is already active we let the keystroke by so that conflicting
  146. ; hot-keys will work.
  147.  
  148. new09int PROC  FAR
  149.  
  150.          sti
  151.          pushf                           ; save the flags
  152.          push      ax                    ; and a register that gets used
  153.          in        al,60h                ; get the keystroke
  154.          cmp       al,cs:[scancode]      ; is it our key?
  155.          jne       @F                    ; no, so jump to original vector
  156.          mov       ah,2
  157.          int       16h                   ; get the keyboard flags
  158.          and       al,0Fh                ; mask off unused bits
  159.          cmp       al,cs:[shiftstatus]   ; does it match our mask?
  160.          jne       @F                    ; no, so jump to original vector
  161.          cmp       cs:[program_status],FALSE ; are we already active?
  162.          jne       @F                    ; yes, so chain to original vector
  163.          cmp       cs:[request_flag],FALSE   ; do we already want serveice?
  164.          je        L200                  ; yes, so chain to original vector
  165. @@:
  166.          pop       ax                    ; restore used register
  167.          popf                            ; restore flags
  168.          jmp       cs:[old09int]         ; jump to original vector
  169. L200:
  170.          mov       cs:[request_flag],TRUE ; say service is desired
  171.          cli                              ; turn off interrupts
  172.          mov       al,20h                 ; say interrupt is finished
  173.          out       20h,al
  174.          in        al,61h                 ; trash the keystroke
  175.          mov       ah,al
  176.          or        al,80h
  177.          out       61h,al
  178.          jmp       @F                     ; jump to nowhere for delay
  179. @@:
  180.          mov       al,ah
  181.          out       61h,al
  182.          pop       ax                     ; restore used register
  183.          popf                             ; restore flags
  184.          iret                             ; all done
  185.  
  186. new09int ENDP
  187.  
  188. ;----------------------------------------------------------------------------
  189. ; Video BIOS Interrupt Service Routine - 10h
  190. ;----------------------------------------------------------------------------
  191. ; This is an optional interrupt trap.  Change the value of TRAPINT10 to
  192. ; TRUE if you want it compiled.  This one traps the video BIOS interrupt
  193. ; and prevents popping up in the middle of any screen activity.
  194.  
  195. IF  trapInt10
  196.  
  197. new